part of 'card.dart';

class _SummarizingCardWlocStateFactory {
  const _SummarizingCardWlocStateFactory._internal();

  static const _instance = _SummarizingCardWlocStateFactory._internal();

  factory _SummarizingCardWlocStateFactory() {
    return _instance;
  }

  _SummarizingCardWlocState create({
    required BuiltList<LexicalItem> lexicalItems,
    required BuiltMap<String, int> lexicalItemProgressPercentMap,
  }) {
    final lexicalItemModels = lexicalItems.map((lexicalItem) {
      final progressModel = LexicalItemProgressModelFactory().create(
        lexicalItem: lexicalItem,
        progressPercent: lexicalItemProgressPercentMap[lexicalItem.id]!,
      );

      return _LexicalItemModel(
        id: lexicalItem.id,
        title: lexicalItem.title,
        translation: lexicalItem.translation,
        progressModel: progressModel,
      );
    }).toBuiltList();

    return _SummarizingCardWlocState(
      lexicalItemModels: lexicalItemModels,
    );
  }
}
